package org.example.hotel.controller;

import org.example.hotel.dto.RoomStatusDTO;
import org.example.hotel.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @GetMapping("/monitoring")
    public List<RoomStatusDTO> getRoomStatus() {
        return adminService.getAllRoomStatus();
    }

    @PostMapping("/system/start")
    public String startSystem() {
        adminService.startSystem();
        return "空调系统已启动";
    }

    @PostMapping("/system/stop")
    public String stopSystem() {
        adminService.stopSystem();
        return "空调系统已关闭";
    }

    @GetMapping("/system/status")
    public String getSystemStatus() {
        return adminService.getSystemStatus() ? "系统正在运行" : "系统已关闭";
    }
}
